<%#
 Copyright (C) 2017 Jian Chang <aa65535@live.com>
 Licensed to the public under the GNU General Public License v3.
-%>

<% include("cbi/map") %>

<script type="text/javascript">//<![CDATA[
	(function() {
		var getElementById = function(id) {
			return document.getElementById("cbid.<%=self.config%>.<%=self.sid%>." + id);
		};
		var password = getElementById("password");
		var key = getElementById("key");
		var checkCryptoConfig = function() {
			password.className = password.className.replace(/ cbi-input-invalid/g, '');
			key.className = key.className.replace(/ cbi-input-invalid/g, '');
			if (password.value.length == 0 && key.value.length == 0) {
				password.className += ' cbi-input-invalid';
				key.className += ' cbi-input-invalid';
				return false;
			}
			return true;
		};
		password.onkeyup = checkCryptoConfig;
		key.onkeyup = checkCryptoConfig;
		if (key.form) {
			if (!key.form.cbi_validators) {
				key.form.cbi_validators = [];
			}
			key.form.cbi_validators.push(checkCryptoConfig);
		}
		checkCryptoConfig();
	}());
//]]></script>
